package com.example.transactionhintassistant.controller;

import com.example.transactionhintassistant.service.EmailService;
import com.example.transactionhintassistant.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/email")
@Tag(name = "2.邮箱模块")
public class EmailController {
    @Autowired
    private EmailService emailService;

    @GetMapping("/captcha/login/{email}")
    @Operation(summary = "登录验证码")
    public Result<Object> getLoginCaptcha(@PathVariable String email) {
        return emailService.getLoginCaptcha(email);
    }

    @GetMapping("/captcha/pwd/{email}")
    @Operation(summary = "密码修改验证码")
    public Result<Object> getChangePwdCaptcha(@PathVariable String email) {
        return emailService.getChangePwdCaptcha(email);
    }

    @GetMapping("/captcha/oldEmail/{email}")
    @Operation(summary = "旧邮箱验证码", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getOldEmailCaptcha(@PathVariable String email) {
        return emailService.getOldEmailCaptcha(email);
    }

    @GetMapping("/captcha/newEmail/{email}")
    @Operation(summary = "新邮箱验证码", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getNewEmailCaptcha(@PathVariable String email) {
        return emailService.getNewEmailCaptcha(email);
    }

    @GetMapping("/captcha/bindingEmail/{email}")
    @Operation(summary = "绑定邮箱验证码", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getEmailBindingCaptcha(@PathVariable String email) {
        return emailService.getEmailBindingCaptcha(email);
    }
}
